<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    li{
      height: 50px;
      margin-top: 10px;
      background-color: rgb(99, 114, 49);
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="changeLen">改变数组的length</button>
    <ul>
      <li v-for="(item,index) in arr" @click="changeLi(index)" :key="index">
        {{item}}
      </li>
    </ul>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        arr: ['a', 'b', 'c', 'd']
      },
      methods: {
        changeLi(index){
          this.$set(this.arr, index, '值改变了');
        },
        changeLen(){
          this.arr.length = 2;
          console.log(this.arr);
        }
      }
    })
  </script>
</body>
</html>